﻿using Microsoft.AspNetCore.Mvc.Filters;
using System.Transactions;

namespace ConsoleApp7.Filter
{
    public class MyTranFilter : Attribute, IAsyncActionFilter
    {
        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            using TransactionScope transaction = new TransactionScope();
            var result = await next();
            string zhi = ((Microsoft.AspNetCore.Mvc.ContentResult)result.Result).Content;
            if (zhi == "ok")
            {
                transaction.Complete();
            }
        }
    }
}
